<!-- 材料详情弹窗 -->
<template>
  <a-form
    ref="form3"
    class="ele-form-detail"
    :model="materialModalApp.material"
    :label-col="{md: {span: 2}, sm: {span: 4}, xs: {span: 6}}"
    :wrapper-col="{md: {span: 22}, sm: {span: 20}, xs: {span: 18}}">
    <a-descriptions :title="materialModalApp.title" bordered>
      <a-descriptions-item label="标识">
        {{ materialModalApp.material.Eid }}
      </a-descriptions-item>
      <a-descriptions-item label="创建人">
        {{ materialModalApp.material.creatorName }}
      </a-descriptions-item>
      <a-descriptions-item label="名称">
        {{ materialModalApp.material.name }}
      </a-descriptions-item>
      <a-descriptions-item label="材料类别id">
        {{ materialModalApp.material.materialCategoryId }}
      </a-descriptions-item>
      <a-descriptions-item label="状态">
        {{ materialModalApp.material.status }}
      </a-descriptions-item>
      <a-descriptions-item label="创建人ID">
        {{ materialModalApp.material.creatorId }}
      </a-descriptions-item>
      <a-descriptions-item label="备注">
        {{ materialModalApp.material.remark }}
      </a-descriptions-item>
      <a-descriptions-item label="创建时间">
        {{ materialModalApp.material.createDatetime }}
      </a-descriptions-item>
    </a-descriptions>
  </a-form>
</template>

<script>
import {defineComponent, reactive, onMounted, inject} from "vue";
import {useRoute} from "vue-router"
import {MaterialService} from "@/views/restaurant/material/material/materialService";

export default defineComponent({
  setup() {
    const route = useRoute();
    let routeId = route.params.id;
    let materialListApp = inject('materialListApp', reactive({}));
    const materialModalApp = reactive({id: null, material: {}, display: false});

    onMounted(() => {
      materialModalApp.material = {};
      if (routeId) {
        materialModalApp.id = routeId;
      } else if (materialListApp.viewModalShowing) {
        materialModalApp.id = materialListApp.currentId;
        materialModalApp.display = true;
      }
      if (materialModalApp.id) {
        getInfo(materialModalApp.id);
      }
    })

    const getInfo = (id) => {
      MaterialService.findMaterial(id).then((res) => {
        materialModalApp.material = res.data;
        materialModalApp.title = "查看 " + materialModalApp.material.name;
      })
    }

    return {
      materialModalApp,
      routeId,
      getInfo,
    }
  }
})
</script>

<style scoped>
</style>

